﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MuzičkiFeršterker
{
    public partial class SettingsWindow : Form
    {
        public SettingsWindow(string header, TransVar T)
        {
            this.Text = header;
            InitializeComponent();
            labelBackground.Text = T.tBACKGROUNDCOLOR1LABEL;
            labelWindowsBg2.Text = T.tBACKGROUNDCOLOR2LABEL;
            checkBox1.Text = T.tGRADIENTCHECK;
            gradient = true;
            buttonBgColor2.Text = T.tSELECTCOLORBUTTON;
            buttonOpenColordialog.Text = T.tSELECTCOLORBUTTON;
            button1.Text = T.tSELECTCOLORBUTTON;
            groupBox1.Text = T.tGROUPBOX;
            label1.Text = T.tTABBGCOLORLABEL;
            groupBox2.Text = T.tGROUPBOX2;
            labelLanguages.Text = T.tLABELLANGUAGES;
            LanguageSelButton.Text = T.tBUTTONLANGUAGES;
            LanguagesCBox.Text = Settings.Instance.languageFile.getLanguage();
            tv = T;
            
        }
        public Color WindowBgColor;
        public Color WindowBgColor2;
        public Color TabBgColor;
        public bool gradient;
        public TransVar tv;
        public bool langChg = false;

        private void button1_Click(object sender, EventArgs e)
        {
            colorDialog1.ShowDialog();
            textBox1.Text = colorDialog1.Color.ToString();
            WindowBgColor = colorDialog1.Color;          

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                gradient = false;
                textBox2.Enabled = false;
                buttonBgColor2.Enabled = false;

            }
            else
            {
                gradient = true;
                textBox2.Enabled = true;
                buttonBgColor2.Enabled = true;

            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (WindowBgColor.IsEmpty)
            {
                WindowBgColor = Color.WhiteSmoke;
            }
            if (WindowBgColor2.IsEmpty)
            {
                WindowBgColor2 = Color.WhiteSmoke;
            }
            this.DialogResult = DialogResult.OK;
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void SettingsWindow_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
            }
            else if (e.KeyCode == Keys.Enter)
            {
                if (WindowBgColor.IsEmpty)
                {
                    WindowBgColor = Color.WhiteSmoke;
                }
                if (WindowBgColor2.IsEmpty)
                {
                    WindowBgColor2 = Color.WhiteSmoke;
                }
                this.DialogResult = DialogResult.OK;
            }
        }

        private void buttonBgColor2_Click(object sender, EventArgs e)
        {
            ColorDialog color2 = new ColorDialog();
            color2.ShowDialog();
            textBox2.Text = color2.Color.ToString();
            WindowBgColor2 = color2.Color; 
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            ColorDialog color3 = new ColorDialog();
            color3.ShowDialog();
            textBox3.Text = color3.Color.ToString();
            TabBgColor = color3.Color; 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog opf = new OpenFileDialog();
            opf.Filter = "XML Translation file(*.xml)|*.xml";
            if (opf.ShowDialog() == DialogResult.OK)
            {               
                Settings.Instance.AddLanguage(opf.FileName);
                LanguagesCBox.Text = Settings.Instance.languageFile.getLanguage();
                tv = new TransVar(opf.FileName);
                langChg = true;
            }
            
        }
    }
}
